package components;

import bluetooth.BlueCanvasBase;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

import common.CommandString;

import common.CommandType;

/**
 * 控制界面
 * @author cccssw
 * 
 */
public class CtrlPcCanvas extends BlueCanvasBase  {



    //按钮控件

    
    //提示信息
    final String[] strHelp = {
        "ready to input"
    };

    protected void keyPressed(int keyCode) {
        bs.sendMsg(CommandString.BuildCommandString(CommandType.KEY_PRESSED, keyCode));

    }

    protected void keyReleased(int keyCode) {
        bs.sendMsg(CommandString.BuildCommandString(CommandType.KEY_RELEASED, keyCode));
    }

    protected void keyRepeated(int keyCode) {
        bs.sendMsg(CommandString.BuildCommandString(CommandType.KEY_REPEAT, keyCode));
    }

    
    public void paint(Graphics g) {
        // 清空画布
        g.setColor(255, 255, 100);
        g.fillRect(0, 0, this.getWidth(), this.getHeight());
        g.setColor(0, 0, 0);

        //在画布界面填写操作提示信息
        Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
        g.setFont(font);

        for (int i = 0; i < strHelp.length; i++) {
            g.drawString(strHelp[i], 10, 5 + 20 * i, Graphics.TOP | Graphics.LEFT);
        }
    }
}
